﻿using System.Linq;
using System.Text;
using System.Data;
using Maticsoft.DBUtility;
using System.Data.SqlClient;
using System;
using System.Collections.Generic;

namespace ElingOA6_Admin_DSJCJ.DAL
{
    /// <summary>
    /// 相册 数据类
    /// </summary>
    public class Album
    {
        public Album()
        {
        }

        /// <summary>
        /// 获取当前目录下最大顺序号
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        /// <param name="albumClsNo"></param>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public int GetDirMaxSeq(string albumClsNo, string entityNo)
        {
        
            string strSql = "select max(FDispSeq) from t_Album where FAlbumClsNo=@FAlbumClsNo and FEntityNo=@FEntityNo";
            SqlParameter[] parameters = {
                    new SqlParameter("@FAlbumClsNo",SqlDbType.NVarChar,30),
                    new SqlParameter("@FEntityNo",SqlDbType.NVarChar,15) };

            parameters[0].Value = albumClsNo;
            parameters[1].Value = entityNo;

            object obj = DbHelperSQL.GetSingle(strSql, parameters);
            if (null != obj)
            {
                return int.Parse(obj.ToString());
            }
            else
            {
                return 0;
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        public ElingOA6_Admin_DSJCJ.Model.Album GetModel(int albumId)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 FAlbumId,FEmplNo,FEntityNo,FFileName,FFileType,FFileUrl,FFilePath,FCreateDate,FUpdateTime,FDispSeq,FDeptNo,FSize,FIsDelete,FContentTxt,FContentBin,FBGMusicPath,FResponsible,FIsDeptControl,FPlayInterval,FShowDate,FIsSecret,FFileNo,FFileNoDate,FAlbumClsNo from t_Album ");
            strSql.Append(" where FAlbumId=@FAlbumId");
            SqlParameter[] parameters = {
					new SqlParameter("@FAlbumId", SqlDbType.Int,4)
			};
            parameters[0].Value = albumId;

            ElingOA6_Admin_DSJCJ.Model.Album model = new ElingOA6_Admin_DSJCJ.Model.Album();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获取背景音乐地址和图片播放间隔
        /// <creator>wangl</creator>
        /// <date>2014-10-14</date>
        /// </summary>
        /// <param name="FDocId"></param>
        /// <returns></returns>
        public DataSet GetBGMusicPathAndPlayInterval(int albumId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 FBGMusicPath,FPlayInterval from t_Album ");
            strSql.Append(" where  FAlbumId=@FAlbumId ");
            SqlParameter[] parameters = {
					new SqlParameter("@FAlbumId", SqlDbType.Int)};
            parameters[0].Value = albumId;

            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 保存文件数据
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int DocAdd(Model.Album model)
        {
            int result = -1;

            //判断该序号是否已经存在
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT FAlbumClsNo FROM t_Album ");
            strSql.Append(" WHERE FAlbumClsNo=@FAlbumClsNo AND FDispSeq=@FDispSeq");
            SqlParameter[] parameters = {
					new SqlParameter("@FAlbumClsNo", SqlDbType.NVarChar,30),
					new SqlParameter("@FDispSeq", SqlDbType.Int)};
            parameters[0].Value = model.FAlbumClsNo;
            parameters[1].Value = model.FDispSeq;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                //直接添加
                strSql = new StringBuilder();
                strSql.Append("insert into t_Album(");
                strSql.Append("FAlbumClsNo,FFileName,FFileType,FFileUrl,FFilePath,FUpdateTime,FDispSeq,FEmplNo,FEntityNo,FSize,FDeptNo,FResponsible,FIsDeptControl,FContentTxt,FContentBin,FBGMusicPath,FPlayInterval,FShowDate,FIsSecret,FFileNo,FFileNoDate)");
                strSql.Append(" values (");
                strSql.Append("@FAlbumClsNo,@FFileName,@FFileType,@FFileUrl,@FFilePath,@FUpdateTime,@FDispSeq,@FEmplNo,@FEntityNo,@FSize,@FDeptNo,@FResponsible,@FIsDeptControl,@FContentTxt,@FContentBin,@FBGMusicPath,@FPlayInterval,@FShowDate,@FIsSecret,@FFileNo,@FFileNoDate)");
                strSql.Append(";select IDENT_CURRENT('t_Album')");
                SqlParameter[] parameters1 = {
					new SqlParameter("@FAlbumClsNo", SqlDbType.NVarChar,30),
					new SqlParameter("@FFileName", SqlDbType.NVarChar,200),
					new SqlParameter("@FFileType", SqlDbType.NVarChar,200),
					new SqlParameter("@FFileUrl", SqlDbType.NVarChar,200),
					new SqlParameter("@FFilePath", SqlDbType.NVarChar,200),
					new SqlParameter("@FUpdateTime", SqlDbType.DateTime),
					new SqlParameter("@FDispSeq", SqlDbType.Int),
					new SqlParameter("@FEmplNo", SqlDbType.NVarChar,15),
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
                    new SqlParameter("@FSize",SqlDbType.BigInt),
                    new SqlParameter("@FDeptNo",SqlDbType.NVarChar,12),
                    new SqlParameter("@FResponsible",SqlDbType.NVarChar,80),
                    new SqlParameter("@FIsDeptControl",SqlDbType.Int),
                    new SqlParameter("@FContentTxt", SqlDbType.Text),
					new SqlParameter("@FContentBin", SqlDbType.Image),
                    new SqlParameter("@FBGMusicPath", SqlDbType.NVarChar,255),
                    new SqlParameter("@FPlayInterval", SqlDbType.Int),
                    new SqlParameter("@FShowDate", SqlDbType.DateTime),
                    new SqlParameter("@FIsSecret", SqlDbType.Char,1),
                    new SqlParameter("@FFileNo", SqlDbType.NVarChar,100),
                    new SqlParameter("@FFileNoDate", SqlDbType.DateTime)};
                parameters1[0].Value = model.FAlbumClsNo;
                parameters1[1].Value = model.FFileName;
                parameters1[2].Value = model.FFileType;
                parameters1[3].Value = model.FFileUrl;
                parameters1[4].Value = model.FFilePath;
                parameters1[5].Value = model.FUpdateTime;
                parameters1[6].Value = model.FDispSeq;
                parameters1[7].Value = model.FEmplNo;
                parameters1[8].Value = model.FEntityNo;
                parameters1[9].Value = model.FSize;
                parameters1[10].Value = model.FDeptNo;
                parameters1[11].Value = model.FResponsible;
                parameters1[12].Value = model.FIsDeptControl;
                parameters1[13].Value = model.FContentTxt;
                parameters1[14].Value = model.FContentBin;
                parameters1[15].Value = model.FBGMusicPath;
                parameters1[16].Value = model.FPlayInterval;
                parameters1[17].Value = model.FShowDate;
                parameters1[18].Value = model.FIsSecret;
                parameters1[19].Value = model.FFileNo;
                parameters1[20].Value = model.FFileNoDate;

                object obj1 = DbHelperSQL.GetSingle(strSql.ToString(), parameters1);
                if (obj1 == null)
                {
                    return -1;
                }
                else
                {
                    return Convert.ToInt32(obj1);
                }

            }
            else
            {
                //事务处理，先更新所有大于该序号的记录，然后再添加
                List<CommandInfo> cmdList = new List<CommandInfo>();
                CommandInfo cmds = new CommandInfo();
                strSql = new StringBuilder();
                strSql.Append("UPDATE t_Album SET FDispSeq=FDispSeq+1 ");
                strSql.Append(" WHERE FAlbumClsNo=@FAlbumClsNo AND FDispSeq>=@FDispSeq");
                SqlParameter[] parameters2 = {
					new SqlParameter("@FAlbumClsNo", SqlDbType.NVarChar,30),
					new SqlParameter("@FDispSeq", SqlDbType.Int)};
                parameters2[0].Value = model.FAlbumClsNo;
                parameters2[1].Value = model.FDispSeq;

                cmds.CommandText = strSql.ToString();
                cmds.Parameters = parameters2;
                cmdList.Add(cmds);

                strSql = new StringBuilder();
                cmds = new CommandInfo();
                strSql.Append("insert into t_Album(");
                strSql.Append("FAlbumClsNo,FFileName,FFileType,FFileUrl,FFilePath,FUpdateTime,FDispSeq,FEmplNo,FEntityNo,FSize,FDeptNo,FResponsible,FIsDeptControl,FContentTxt,FContentBin,FBGMusicPath,FPlayInterval,FShowDate,FIsSecret,FFileNo,FFileNoDate)");
                strSql.Append(" values (");
                strSql.Append("@FAlbumClsNo,@FFileName,@FFileType,@FFileUrl,@FFilePath,@FUpdateTime,@FDispSeq,@FEmplNo,@FEntityNo,@FSize,@FDeptNo,@FResponsible,@FIsDeptControl,@FContentTxt,@FContentBin,@FBGMusicPath,@FPlayInterval,@FShowDate,@FIsSecret,@FFileNo,@FFileNoDate)");
                strSql.Append(";select @returnID=IDENT_CURRENT('t_Album')");
                SqlParameter[] parameters3 = {
					new SqlParameter("@FAlbumClsNo", SqlDbType.NVarChar,30),
					new SqlParameter("@FFileName", SqlDbType.NVarChar,200),
					new SqlParameter("@FFileType", SqlDbType.NVarChar,200),
					new SqlParameter("@FFileUrl", SqlDbType.NVarChar,200),
					new SqlParameter("@FFilePath", SqlDbType.NVarChar,200),
					new SqlParameter("@FUpdateTime", SqlDbType.DateTime),
					new SqlParameter("@FDispSeq", SqlDbType.Int),
					new SqlParameter("@FEmplNo", SqlDbType.NVarChar,15),
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
                    new SqlParameter("@FSize",SqlDbType.BigInt),
                    new SqlParameter("@FDeptNo",SqlDbType.NVarChar,12),
                    new SqlParameter("@FResponsible",SqlDbType.NVarChar,80),
                    new SqlParameter("@FIsDeptControl",SqlDbType.Int),
                    new SqlParameter("@FContentTxt", SqlDbType.Text),
					new SqlParameter("@FContentBin", SqlDbType.Image),
                    new SqlParameter("@FBGMusicPath", SqlDbType.NVarChar,255),
                    new SqlParameter("@FPlayInterval", SqlDbType.Int),
                    new SqlParameter("@FShowDate", SqlDbType.DateTime),
                    new SqlParameter("@FIsSecret", SqlDbType.Char,1),
                    new SqlParameter("@FFileNo", SqlDbType.NVarChar,100),
                    new SqlParameter("@FFileNoDate", SqlDbType.DateTime),
                    new SqlParameter("@returnID", SqlDbType.Int)};
                parameters3[0].Value = model.FAlbumClsNo;
                parameters3[1].Value = model.FFileName;
                parameters3[2].Value = model.FFileType;
                parameters3[3].Value = model.FFileUrl;
                parameters3[4].Value = model.FFilePath;
                parameters3[5].Value = model.FUpdateTime;
                parameters3[6].Value = model.FDispSeq;
                parameters3[7].Value = model.FEmplNo;
                parameters3[8].Value = model.FEntityNo;
                parameters3[9].Value = model.FSize;
                parameters3[10].Value = model.FDeptNo;
                parameters3[11].Value = model.FResponsible;
                parameters3[12].Value = model.FIsDeptControl;
                parameters3[13].Value = model.FContentTxt;
                parameters3[14].Value = model.FContentBin;
                parameters3[15].Value = model.FBGMusicPath;
                parameters3[16].Value = model.FPlayInterval;
                parameters3[17].Value = model.FShowDate;
                parameters3[18].Value = model.FIsSecret;
                parameters3[19].Value = model.FFileNo;
                parameters3[20].Value = model.FFileNoDate;
                parameters3[21].Direction = ParameterDirection.Output;

                cmds.CommandText = strSql.ToString();
                cmds.Parameters = parameters3;
                cmdList.Add(cmds);
                if (cmdList.Count > 0)
                {
                    try
                    {
                        DbHelperSQL.ExecuteSqlTranWithString(cmdList);
                        //result = 1;
                        result = int.Parse(parameters3[19].Value.ToString());
                    }
                    catch
                    {
                        result = -1;
                    }
                }
                return result;

            }
        }
        /// <summary>
        /// 更新文件数据
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        /// <param name="model"></param>
        /// <param name="oldSeq"></param>
        public void UpdateDoc(Model.Album model, int oldSeq)
        {
            //判断该序号是否已经存在
            StringBuilder strSql = new StringBuilder();
            //事务处理，先更新所有大于该序号的记录，然后再添加
            List<CommandInfo> cmdList = new List<CommandInfo>();
            CommandInfo cmds = new CommandInfo();
            if (oldSeq != model.FDispSeq)
            {
                strSql = new StringBuilder();
                if (oldSeq <= model.FDispSeq)
                {
                    strSql.Append("UPDATE t_Album SET FDispSeq=FDispSeq-1 ");
                    strSql.Append(" WHERE FAlbumClsNo=@FAlbumClsNo AND FDispSeq>@FOldDispSeq AND FDispSeq<=@FDispSeq");
                }
                else
                {
                    strSql.Append("UPDATE t_Album SET FDispSeq=FDispSeq+1 ");
                    strSql.Append(" WHERE FAlbumClsNo=@FAlbumClsNo AND FDispSeq<@FOldDispSeq AND FDispSeq>=@FDispSeq");
                }
                SqlParameter[] parameters2 = {
					new SqlParameter("@FAlbumClsNo", SqlDbType.NVarChar,30),
					new SqlParameter("@FDispSeq", SqlDbType.Int),
                    new SqlParameter("@FOldDispSeq", SqlDbType.Int)};
                parameters2[0].Value = model.FAlbumClsNo;
                parameters2[1].Value = model.FDispSeq;
                parameters2[2].Value = oldSeq;


                cmds.CommandText = strSql.ToString();
                cmds.Parameters = parameters2;
                cmdList.Add(cmds);

            }


            //直接更新
            strSql = new StringBuilder();
            cmds = new CommandInfo();
            strSql.Append("update t_Album set ");
            strSql.Append("FAlbumClsNo=@FAlbumClsNo,");
            strSql.Append("FFileName=@FFileName,");
            strSql.Append("FFileType=@FFileType,");
            strSql.Append("FFileUrl=@FFileUrl,");
            strSql.Append("FFilePath=@FFilePath,");
            strSql.Append("FUpdateTime=@FUpdateTime,");
            strSql.Append("FDispSeq=@FDispSeq,");
            strSql.Append("FEntityNo=@FEntityNo,");
            strSql.Append("FSize=@FSize,");
            strSql.Append("FDeptNo=@FDeptNo,");
            strSql.Append("FResponsible=@FResponsible,");
            strSql.Append("FIsDeptControl=@FIsDeptControl,");
            strSql.Append("FShowDate=@FShowDate,");
            strSql.Append("FIsSecret=@FIsSecret,");
            strSql.Append("FContentTxt=@FContentTxt,");
            strSql.Append("FContentBin=@FContentBin,");
            strSql.Append("FBGMusicPath=@FBGMusicPath,");
            strSql.Append("FPlayInterval=@FPlayInterval,");
            strSql.Append("FFileNo=@FFileNo,");
            strSql.Append("FFileNoDate=@FFileNoDate");
            strSql.Append(" where FAlbumId=@FAlbumId ");
            SqlParameter[] parameters3 = {
					new SqlParameter("@FAlbumId", SqlDbType.Int),
					new SqlParameter("@FAlbumClsNo", SqlDbType.NVarChar),
					new SqlParameter("@FFileName", SqlDbType.NVarChar,200),
					new SqlParameter("@FFileType", SqlDbType.NVarChar,200),
					new SqlParameter("@FFileUrl", SqlDbType.NVarChar,200),
					new SqlParameter("@FFilePath", SqlDbType.NVarChar,200),
					new SqlParameter("@FUpdateTime", SqlDbType.DateTime),
					new SqlParameter("@FDispSeq", SqlDbType.Int),
					new SqlParameter("@FEmplNo", SqlDbType.NVarChar,15),
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
                    new SqlParameter("@FSize", SqlDbType.BigInt),
                    new SqlParameter("@FDeptNo", SqlDbType.NVarChar,12),
                    new SqlParameter("@FResponsible",SqlDbType.NVarChar,80),
                    new SqlParameter("@FIsDeptControl",SqlDbType.Int),
                    new SqlParameter("@FShowDate", SqlDbType.DateTime),
                    new SqlParameter("@FIsSecret", SqlDbType.Char,1),
                    new SqlParameter("@FContentTxt", SqlDbType.Text),
					new SqlParameter("@FContentBin", SqlDbType.Image),
					new SqlParameter("@FBGMusicPath", SqlDbType.NVarChar,255),
                    new SqlParameter("@FPlayInterval", SqlDbType.Int),
                    new SqlParameter("@FFileNo", SqlDbType.NVarChar,100),
                    new SqlParameter("@FFileNoDate", SqlDbType.DateTime)};
            parameters3[0].Value = model.FAlbumId;
            parameters3[1].Value = model.FAlbumClsNo;
            parameters3[2].Value = model.FFileName;
            parameters3[3].Value = model.FFileType;
            parameters3[4].Value = model.FFileUrl;
            parameters3[5].Value = model.FFilePath;
            parameters3[6].Value = model.FUpdateTime;
            parameters3[7].Value = model.FDispSeq;
            parameters3[8].Value = model.FEmplNo;
            parameters3[9].Value = model.FEntityNo;
            parameters3[10].Value = model.FSize;
            parameters3[11].Value = model.FDeptNo;
            parameters3[12].Value = model.FResponsible;
            parameters3[13].Value = model.FIsDeptControl;
            parameters3[14].Value = model.FShowDate;
            parameters3[15].Value = model.FIsSecret;
            parameters3[16].Value = model.FContentTxt;
            parameters3[17].Value = model.FContentBin;
            parameters3[18].Value = model.FBGMusicPath;
            parameters3[19].Value = model.FPlayInterval;
            parameters3[20].Value = model.FFileNo;
            parameters3[21].Value = model.FFileNoDate;

            cmds.CommandText = strSql.ToString();
            cmds.Parameters = parameters3;
            cmdList.Add(cmds);

            if (cmdList.Count > 0)
            {
                try
                {
                    DbHelperSQL.ExecuteSqlTranWithString(cmdList);
                }
                catch
                {

                }
            }

        }
        /// <summary>
        /// 获取二进制
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        /// <param name="albumId"></param>
        /// <returns></returns>
        public byte[] GetContentBin(int albumId)
        {
            string strSql = "select  top 1 FContentBin from t_Album where FAlbumId=@FAlbumId";
            SqlParameter[] parameters = {
					new SqlParameter("@FAlbumId", SqlDbType.Int)};
            parameters[0].Value = albumId;

            object obj = DbHelperSQL.GetSingle(strSql, parameters);
            if (null != obj)
            {
                return (byte[])obj;
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 删除一条数据
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        public void Delete(int albumId)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from t_Album ");
            strSql.Append(" where FAlbumId=@FAlbumId");
            SqlParameter[] parameters = {
					new SqlParameter("@FAlbumId", SqlDbType.Int,4)
                };
            parameters[0].Value = albumId;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 得到一个对象实体
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        public ElingOA6_Admin_DSJCJ.Model.Album DataRowToModel(DataRow row)
        {
            ElingOA6_Admin_DSJCJ.Model.Album model = new ElingOA6_Admin_DSJCJ.Model.Album();
            if (row != null)
            {
                if (row["FAlbumId"] != null && row["FAlbumId"].ToString() != "")
                {
                    model.FAlbumId = int.Parse(row["FAlbumId"].ToString());
                }
                if (row["FEmplNo"] != null)
                {
                    model.FEmplNo = row["FEmplNo"].ToString();
                }
                if (row["FEntityNo"] != null)
                {
                    model.FEntityNo = row["FEntityNo"].ToString();
                }
                if (row["FFileName"] != null)
                {
                    model.FFileName = row["FFileName"].ToString();
                }
                if (row["FFileType"] != null)
                {
                    model.FFileType = row["FFileType"].ToString();
                }
                if (row["FFileUrl"] != null)
                {
                    model.FFileUrl = row["FFileUrl"].ToString();
                }
                if (row["FFilePath"] != null)
                {
                    model.FFilePath = row["FFilePath"].ToString();
                }
                if (row["FCreateDate"] != null)
                {
                    model.FCreateDate = DateTime.Parse(row["FCreateDate"].ToString());
                    
                }
                if (row["FUpdateTime"] != null && row["FUpdateTime"].ToString() != "")
                {
                    model.FUpdateTime = DateTime.Parse(row["FUpdateTime"].ToString());
                }
                if (row["FDispSeq"] != null && row["FDispSeq"].ToString() != "")
                {
                    model.FDispSeq = int.Parse(row["FDispSeq"].ToString());
                }
                if (row["FDeptNo"] != null)
                {
                    model.FDeptNo = row["FDeptNo"].ToString();
                }
                if (row["FSize"] != null && row["FSize"].ToString() != "")
                {
                    model.FSize = long.Parse(row["FSize"].ToString());
                }
                if (row["FIsDelete"] != null && row["FIsDelete"].ToString() != "")
                {
                    model.FIsDelete = int.Parse(row["FIsDelete"].ToString());
                }
                if (row["FContentTxt"] != null)
                {
                    model.FContentTxt = row["FContentTxt"].ToString();
                }
                if (row["FContentBin"] != null && row["FContentBin"].ToString() != "")
                {
                    model.FContentBin = (byte[])row["FContentBin"];
                }
                if (row["FBGMusicPath"] != null)
                {
                    model.FBGMusicPath = row["FBGMusicPath"].ToString();
                }
                if (row["FResponsible"] != null)
                {
                    model.FResponsible = row["FResponsible"].ToString();
                }
                if (row["FIsDeptControl"] != null && row["FIsDeptControl"].ToString() != "")
                {
                    model.FIsDeptControl = int.Parse(row["FIsDeptControl"].ToString());
                }
                if (row["FPlayInterval"] != null && row["FPlayInterval"].ToString() != "")
                {
                    model.FPlayInterval = int.Parse(row["FPlayInterval"].ToString());
                }
                if (row["FShowDate"] != null && row["FShowDate"].ToString() != "")
                {
                    model.FShowDate = DateTime.Parse(row["FShowDate"].ToString());
                }
                if (row["FIsSecret"] != null)
                {
                    model.FIsSecret = row["FIsSecret"].ToString();
                }
                if (row["FFileNo"] != null)
                {
                    model.FFileNo = row["FFileNo"].ToString();
                }
                if (row["FFileNoDate"] != null && row["FFileNoDate"].ToString() != "")
                {
                    model.FFileNoDate = DateTime.Parse(row["FFileNoDate"].ToString());
                }
                if (row["FAlbumClsNo"] != null)
                {
                    model.FAlbumClsNo = row["FAlbumClsNo"].ToString();
                }
            }
            return model;
        }

    }
}
